package com.sumainfor.pc.market.controller.directormarket;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.service.DmCommunityService;
import com.sumainfor.pc.market.service.DmMediumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Date 2018年11月7日
 * @Describe 小区项目
 */
@RestController
@RequestMapping("/directormarket/DmCommunityController")
public class DmCommunityController implements Serializable {
    @Autowired
    DmCommunityService dmCommunityService;
    /**
     * 分页查询小区项目
     */
    @GetMapping("/getCommunityList")
    public JsonResult getCommunityList(@RequestParam Map<String,Object> params, Pager pager){
        JsonResult result=new JsonResult();
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout=dmCommunityService.getCommunityListCount(params);
        System.out.println("总数:"+cout);
        if(cout==0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(), params,cout);
        }
        List<Map<String,Object>> getCommunityList=dmCommunityService.getCommunityList(params);
        result=pageUtils.getJsonResult(getCommunityList, params, cout);
        return result;
    }
    /**
     * 修改项目，选择项目的服务中心
     */
    @PostMapping("/updateCommunity")
    public JsonResult updateCommunity(@RequestBody Map<String,Object>params){
        JsonResult result=new JsonResult();
        int resultsjk=dmCommunityService.updateCommunity(params);
        if (resultsjk>0){
            result.putSuccess("修改成功");
        }else{
            result.putFailed("服务器繁忙");
        }
        return  result;
    }
}
